package org.dtrd.modules.quartz.job;

import lombok.extern.slf4j.Slf4j;
import org.dtrd.common.util.DateUtils;
import org.dtrd.modules.achievement.service.IDtrdEntRdSigninAchievementService;
import org.dtrd.modules.achievement.service.impl.DtrdEntRdSigninRecordServiceImpl;
import org.quartz.*;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * 成就相关定时任务
 *
 * @author 萧
 * @date:2021-09-22 10:18 下午
 **/
@PersistJobDataAfterExecution
@DisallowConcurrentExecution
@Slf4j
public class AchievementJob implements Job {

    @Autowired
    DtrdEntRdSigninRecordServiceImpl signinRecordService;

    @Autowired
    private IDtrdEntRdSigninAchievementService achievementService;

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        log.info("AchievementJob.execute.[context] 成就统计定时任务 执行时间 ------  " + DateUtils.formatDateTime());
        long time = System.nanoTime();
        signinRecordService.summaryAchievement();
        achievementService.summaryCheckinDays();
        log.info("AchievementJob.execute.[context] 执行结束 执行耗时 " + (System.nanoTime() - time) + "纳秒");
    }
}
